package studio.raptor.extractor.segment.holder;

import java.util.HashSet;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import studio.raptor.extractor.segment.server.ExtractorServer;

/**
 * Created by liuyong8 on 2017/8/9.
 */
public class ExtractorServerHolder {

  private static final Logger log = LoggerFactory.getLogger(ExtractorServerHolder.class);

  private static Set<ExtractorServer> servers = new HashSet<>();

  public static void addServer(ExtractorServer extractorServer) {
    servers.add(extractorServer);
  }

  public static void startUp() throws Exception {
    for (ExtractorServer server : servers) {
      server.startup();
      log.info("server have started,kindId = {}",server.getServerConfig().getKindId());
    }
  }

  public static void shutDown() {
    for (ExtractorServer server : servers) {
      server.shutDown();
      log.info("server have shutdown,kindId = {}",server.getServerConfig().getKindId());
    }
  }
}
